<?php
class Membership_model extends CI_Model{

	function validate(){
		$this->db->where('username',$this->input->post('username'));
		$this->db->where('password', md5($this->input->post('password')));
		
		$query = $this->db->get('active_user');
		
		if ($query->num_rows() == 1){
			return true;
		}
	
	}
	
	function search_active_member(){
		if($this->input->post('search_criteria')){
			$this->db->where($this->input->post('search_query'),$this->input->post('search_criteria'));
			$q = $this->db->get('active_members');
			if($q->num_rows() > 0){
				return $q;
			}
		}else{
			redirect('monitor/monitor_area');
		}
		
		
	
	}
	
	function getActive_member(){

		$q = $this->db->get('active_members');
		
		if($q->num_rows() > 0) {	
			return $q;
		}
	}
	
	function getActiveNumber(){

		$q = $this->db->get('active_members');
		
		return $q->num_rows();
	
	}
	
	function create_member(){
		$new_member_data = array(
			'reference_id' => $this->input->post('reference_id'),
			'firstname' => $this->input->post('firstname'),
			'middlename' => $this->input->post('middlename'),
			'lastname' => $this->input->post('lastname'),
			'dob' => $this->input->post('dob'),
		
		);
		
		$insert = $this->db->insert('member',$new_member_data);
		return $insert;
	
	}
}